home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / utility / utilmisc / maestix.lha / Maestix / demos / RealtimeEcho.s < prev    next >
Text File  |  1995-06-26  |  6KB  |  151 lines

  1. *****************************************************************
  2. *                                                               *
  3. *       maestix.library-Demo:   Realtime FX                     *
  4. *                                                               *
  5. *****************************************************************
  6. *
  7. *       Programmed by           Richard Körber
  8. *       Date                    1995-06-26
  9. *
  10. *****************************************************************
  11. *  This  demonstration  shows  the  realtime effect feature of  *
  12. *  the  maestix library.   It allocates the  Maestro soundcard  *
  13. *  and switches to realtime effect.                             *
  14. *****************************************************************
  15.  
  16.         INCDIR  "include:"
  17.         INCLUDE exec.i                  ; Library call macros
  18.         INCLUDE intuition.i
  19.         INCLUDE graphics.i
  20.         INCLUDE dos.i
  21.         INCLUDE maestix.i
  22.         INCLUDE libraries/maestix.i     ;Reference includes
  23.         INCLUDE intuition/intuition.i
  24.         INCLUDE dos/dostags.i
  25.         INCLUDE exec/ports.i
  26.  
  27.  
  28. BUFFMS          EQU     333     ;<- Buffer duration in milliseconds
  29. VOLUME          EQU     180     ;<- Echo starting volume (0..256)
  30. DECAY           EQU     256     ;<- Decay of each echo loop (0..256)
  31.  
  32. RATE        EQU    44100    ;<- Sampling rate
  33.  
  34.  
  35.         SECTION text,CODE
  36.  
  37. BUFFSIZE        EQU     ((BUFFMS*2*RATE)/1000/2)*2 ;do not change!
  38.  
  39. *---------------------------------------------------------------*
  40. *       == START OF PROGRAM ==                                  *
  41. *                                                               *
  42. start   ;-- Open all libraries -----------------;
  43.         lea     maestname(PC),a1        ;maestix
  44.         moveq   #39,d0                  ; V39+
  45.         exec    OpenLibrary             ; open
  46.         move.l  d0,maestbase            ; store base
  47.         beq     error1                  ; not found!
  48.         lea     intuiname(PC),a1        ;intuition
  49.         moveq   #36,d0                  ; V36+
  50.         exec    OpenLibrary             ; open
  51.         move.l  d0,intuibase            ; store base
  52.         beq     error2
  53.     ;-- Allocate Maestro -------------------;
  54.         sub.l   a0,a0                   ;no tags
  55.         maest   AllocMaestro
  56.         move.l  d0,maestro              ;^Maestro base
  57.         beq     error3
  58.     ;-- Set Modus --------------------------;
  59.         move.l  maestro(PC),a0          ;^Maestro base
  60.         lea     modustags(PC),a1        ;^Modus tags
  61.         maest   SetMaestro              ;set it now
  62.         move.l  maestro(PC),a0          ;^Maestro base
  63.         lea     realtags(PC),a1
  64.         maest   StartRealtime
  65.     ;-- Open a window ----------------------;
  66.         sub.l   a0,a0                   ;no newwindow struct
  67.         lea     windowtags(PC),a1       ; but loads of tags
  68.         intui   OpenWindowTagList
  69.         move.l  d0,window
  70.         beq     error4
  71.     ;-- Wait for reply (main loop) ---------;
  72. .mainloop       move.l  window(PC),a0           ;window message?
  73.         move.l  wd_UserPort(a0),a0      ; ^message port
  74.         exec    WaitPort
  75. .nextmsg        move.l  window(PC),a0           ;window message?
  76.         move.l  wd_UserPort(a0),a0      ; ^message port
  77.         exec    GetMsg                  ; try to get it...
  78.         tst.l   d0                      ; got one?
  79.         beq.b   .mainloop               ; nope: wait for next msg
  80.     ;---- got a window event ---------------;
  81.         move.l  d0,a0                   ;^IDCMP-message -> a0
  82.         cmp.l   #IDCMP_CLOSEWINDOW,im_Class(a0) ;close window?
  83.         bne.b   .nextmsg                ; no -> look for next msg
  84.     ;-- Exit program -----------------------;
  85. exit            move.l  window(PC),a0           ;Close output window
  86.         intui   CloseWindow
  87. error4          move.l  maestro(PC),a0          ;Stop realtime
  88.         maest   StopRealtime
  89.         move.l  maestro(PC),a0          ;Set maestro free
  90.         maest   FreeMaestro
  91. error3          move.l  intuibase(PC),a1        ;close intuition library
  92.         exec    CloseLibrary
  93. error2          move.l  maestbase(PC),a1        ;close maestix library
  94.         exec    CloseLibrary
  95. error1          moveq   #0,d0                   ;Reply 0
  96.         rts                             ;back to CLI
  97.  
  98. *---------------------------------------------------------------*
  99. *       == DATA SECTION ==                                      *
  100. *                                                               *
  101. maestbase       dc.l    0                       ;^Maestix Lib Base
  102. intuibase       dc.l    0                       ;^Intuition Lib Base
  103. maestro         dc.l    0                       ;^Maestro Base
  104. window          dc.l    0                       ;^Window structure
  105.  
  106. modustags       dc.l    MTAG_Output,OUTPUT_FIFO  ;Input -> Output
  107.         dc.l    MTAG_Input,INPUT_STD     ;Custom input
  108.         dc.l    MTAG_CopyProh,CPROH_OFF  ;No copy protection
  109.         dc.l    MTAG_Emphasis,EMPH_INPUT ;Emphasis see input
  110.         dc.l    MTAG_Source,SRC_INPUT    ;Source see input
  111.         dc.l    MTAG_Rate,RATE_INPUT     ;Rate see input
  112.         dc.l    TAG_DONE
  113.  
  114. realtags        dc.l    MTAG_Effect,11  ;Echo the signal
  115.         dc.l    MTAG_A0,torus    ;^to torus structure
  116.         dc.l    MTAG_D2,VOLUME    ;entry volume
  117.         dc.l    MTAG_D3,DECAY    ;decay volume
  118.         dc.l    TAG_DONE
  119.  
  120. torus           dc.l    buff_l,buff_r,BUFFSIZE,0 ;ptr to buffers and size
  121.     
  122.  
  123. windowtags      dc.l    WA_IDCMP,IDCMP_CLOSEWINDOW ;<- New window's tags
  124.         dc.l    WA_Title,.title
  125.         dc.l    WA_InnerWidth,150
  126.         dc.l    WA_InnerHeight,0
  127.         dc.l    WA_DragBar,-1
  128.         dc.l    WA_DepthGadget,-1
  129.         dc.l    WA_CloseGadget,-1
  130.         dc.l    WA_Activate,-1
  131.         dc.l    WA_RMBTrap,-1
  132.         dc.l    TAG_DONE
  133. .title          dc.b    "Realtime FX",0
  134.         even
  135.  
  136. maestname       dc.b    "maestix.library",0     ;Maestix name
  137. intuiname       dc.b    "intuition.library",0   ;Intuition name
  138.         even
  139.  
  140.  
  141.         SECTION buffer,BSS
  142.  
  143. buff_l          ds.b    BUFFSIZE        ;left torus
  144. buff_r          ds.b    BUFFSIZE        ;right torus
  145.  
  146.  
  147. *---------------------------------------------------------------*
  148. *       == END ==                                               *
  149. *                                                               *
  150.         END
  151.